<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="root">
			<button @click.once="add">添加一个老刘</button>
			<ul>
				<li v-for="(p,index) in persons" :key="index">{{p.id}}-{{p.name}}-{{p.age}}
					
				</li>
			</ul>
			<!-- <ul>
				<li v-for="(c,index) in car" :key="index">
					{{c}},{{index}}
				</li>
			</ul> -->
		</div>
		<script type="text/javascript">
			const vm = new Vue({
				el: '#root',
				data: {
					persons: [{
							id: '001',
							name: '张三',
							age: 18
						},
						{
							id: '002',
							name: '李四',
							age: 19
						},
						{
							id: '003',
							name: '王五',
							age: 20
						}
					],
					// car:{
					// 	type:'SUV',
					// 	price:'100w',
					// 	color:'black'
					// }
				},
				methods: {
					add() {
						const p = {
							id: '004',
							name: '老刘',
							age: 21
						}
						this.persons.unshift(p)
					}
				}
			})
		</script>
	</body>
</html>
